package cn.strive.eams.attachment.controller;

import cn.strive.eams.attachment.pojo.dto.AttachmentSaveParam;
import cn.strive.eams.attachment.pojo.vo.AttachmentVO;
import cn.strive.eams.attachment.service.AttachmentService;
import cn.strive.eams.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.strive.eams.attachment.pojo.dto.AttachmentQuery;


import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/attachment")
public class AttachmentController {
    @Autowired
    private AttachmentService attachmentService;

    @GetMapping("/select")
    public JsonResult selectAttachment(AttachmentQuery attachmentQuery){
        log.debug("查询所有附件表信息：attachmentQuery={}",attachmentQuery);
        List<AttachmentVO> list = attachmentService.selectAttachment(attachmentQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveAttachment(AttachmentSaveParam attachmentSaveParam){
        log.debug("保存附件表信息：attachmentSaveParam={}",attachmentSaveParam);
        attachmentService.saveAttachment(attachmentSaveParam);
        return JsonResult.ok();
    }
    @DeleteMapping("/delete/{id}")
    public JsonResult deleteAttachment(@PathVariable Long id){
        log.debug("删除附件表信息：id={}",id);
        attachmentService.deleteAttachment(id);
        return JsonResult.ok();
    }


}
